<template>
	<view>
		<view class="main">
				<view class="avatar">
					<u-avatar :src="src" size="120"></u-avatar>
					<text>账户: {{nickName}}</text>
				</view>
				<view class="set">
					<navigator class="set-item" url="/pages/self-info/self-info">
						<text>个人信息</text>
						<u-icon name="arrow-right"></u-icon>
					</navigator>
					<navigator class="set-item" url="/pages/password/password">
						<text>修改密码</text>
						<u-icon name="arrow-right"></u-icon>
					</navigator>
					<navigator class="set-item" url="/pages/order/order">
						<text>订单列表</text>
						<u-icon name="arrow-right"></u-icon>
					</navigator>
					<navigator class="set-item" url="/pages/feedback/feedback">
						<text>意见反馈</text>
						<u-icon name="arrow-right"></u-icon>
					</navigator>
				</view>
		</view>
		<button @click="show = true">退出登录</button>
		<u-modal v-model="show" :content="content" :title="title" show-cancel-button @confirm="confirm"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: '',
				nickName: '',
				show: false,
				content: '确定要退出吗',
				title: '温馨提示'
			};
		},
		onLoad() {
			this.getUser()
		},
		methods: {
			getUser(){
				this.$request({
					url: '/prod-api/api/common/user/getInfo',
				}).then(res => {
					this.nickName = res.user.nickName
				})
			},
			confirm(){
				uni.removeStorageSync('token')
				uni.showToast({
					title:'退出成功'
				})
				uni.reLaunch({
					url:'/pages/login/login'
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
		background-color: #f7f7f7;
		padding: 20rpx;
			.main{
				border-radius: 20rpx;
				background-color: #fff;
				height: fit-content;
				padding: 20rpx;
				.avatar{
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					padding: 20rpx;
					text{
						margin-top: 20rpx;
					}
				}
				.set{
					display: flex;
					flex-direction: column;
					justify-content: center;
					padding: 20rpx;
					.set-item{
						padding: 20rpx;
						display: flex;
						flex-direction: row;
						justify-content: space-between;
						align-items: center;
						font-size: 32rpx;
						margin-top: 20rpx;
					}
				}
			}
			button{
				width: 100%;
				height: 100rpx;
				background-color: #fa3534;
				color: white;
				padding: 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				margin-top: 40rpx;
			}
	}
</style>
